package analisis.matrizContingencia;

import java.util.List;

/**
 * @file MeanError.java
 * @author Juan Humanes Ferrer
 * @date 14-Marzo-2014
 *
 */
public final class MeanError implements IMedida{

    private double meanError;

    public MeanError() {
        setMeanError(0.0);
    }

    /**
     * Método que retorna el meanError
     *
     * @return meanError
     */
    public double getMeanError() {
        return meanError;
    }

    /**
     * Métodod que modifica el valor de meanError
     *
     * @param meanError
     */
    public void setMeanError(double meanError) {
        this.meanError = meanError;
    }

    /**
     * Método que calcula el meanError
     *
     * @param tp
     * @param tn
     * @param fp
     * @param fn
     * @param valoresMedidas
     */
    @Override
    public void calculaMedida(double tp, double tn, double fp, double fn,List<IMedida> valoresMedidas) {
        double n = tp + tn + fp + fn;
        double result = Double.POSITIVE_INFINITY;

        if (n != 0.0) {
            result = (fp + fn) / n;
        }

        setMeanError(result);
    }
    
    @Override
    public Double verValor(){
        return getMeanError();
    }
}
